/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 黎鹤舞
 * Date: 2023-11-15
 * Time: 20:26
 */


//父类 图形类
class Shape {
    public void draw() {
        System.out.println("画图形!");
    }
}


//子类：圆形类
class Cycle extends Shape {

    //方法的重写
    @Override       //重写方法注解；如果下面的方法名不是重写方法，则编译错误
    public void draw() {
        System.out.println("⚪");
    }

}


//子类: 矩形类
class Rect extends Shape {

    @Override
    public void draw() {
        System.out.println("矩形");
    }
}

class Person {
    private String name = "张三";
    int age = 18;

    //用来传递private修饰的name的值
    public String getName() {
        return name;
    }

    //用来修改private修饰的name的值
    public void setName(String name) {
        this.name = name;
    }
}

class Student extends Person {

    public String gender;
}
public class Test {


    //private关键字测试
    public static void main(String[] args) {

        Person person = new Person();
        Person p = new Student();

        //编译均无法通过，因为String name 属性被 private修饰
        System.out.println("修改之前:" + person.getName());
        person.setName("李四");
        System.out.println("修改之后：" +person.getName());
//        System.out.println(p.name);
    }


    //多态:
    public static void drawMap(Shape shape) {
        shape.draw();
    }
    //方法重写的练习
    public static void main2(String[] args) {
        drawMap(new Rect());

        Cycle cycle = new Cycle();
        drawMap(cycle);
    }



    public static void main1(String[] args) {

        //多态的练习
        //1.向上转型
        Animal animal = new Dog("twh",18,"yellow");
        animal.eat();
    }
}
